﻿using System.Collections.Generic;

namespace Fetches.Fetch.Utils
{
    public class ListHelper
    {
        public static IList<List<T>> GetBlockList<T>(IList<T> list, int blockSize = 10)
        {
            List<List<T>> result = new List<List<T>>();
            var temp = new List<T>();
            for (int i = 0; i < list.Count; i++)
            {
                temp.Add(list[i]);
                if ((i + 1) % blockSize == 0 && i > 0)
                {
                    result.Add(temp);
                    temp = new List<T>();
                }

                if (i == list.Count - 1)
                {
                    result.Add(temp);
                }
            }

            return result;

        }
    }
}
